package org.example.factory;

import com.almasb.fxgl.core.math.FXGLMath;
import com.almasb.fxgl.dsl.FXGL;
import com.almasb.fxgl.dsl.FXGLForKtKt;
import com.almasb.fxgl.entity.Entity;
import com.almasb.fxgl.entity.EntityFactory;
import com.almasb.fxgl.entity.SpawnData;
import com.almasb.fxgl.entity.Spawns;
import com.almasb.fxgl.physics.PhysicsComponent;
import com.almasb.fxgl.texture.Texture;
import javafx.geometry.Point2D;
import javafx.geometry.Rectangle2D;
import javafx.scene.text.Text;
import org.example.constans.TypeEnum;
import org.example.data.ObjsItem;

import java.io.RandomAccessFile;
import java.util.UUID;

public class GraspedFactory implements EntityFactory {

    @Spawns("smallStone")
    public Entity smallStone(SpawnData data) {
        Texture node = new Texture(FXGL.image("stone/small_stone.png"));
        node.setFitHeight(node.getHeight() / 5);
        node.setFitWidth(node.getWidth() / 5);
        Entity build = FXGL.entityBuilder(data).zIndex(10)
                .at((Point2D) data.get("pos"))
                .type(TypeEnum.STONE).collidable()
                .viewWithBBox(node)
                .build();
        ObjsItem info = data.get("info");
        build.setProperty("weight",info.weight());
        build.setProperty("money",info.money());
        return build;
    }

    @Spawns("midStone")
    public Entity midStone(SpawnData data) {
        Texture node = new Texture(FXGL.image("stone/mid_stone.png"));
        node.setFitWidth(95.8);
        node.setFitHeight(79.4);
        Entity build = FXGL.entityBuilder(data).zIndex(10)
                .at((Point2D) data.get("pos"))
                .type(TypeEnum.STONE).collidable()
                .viewWithBBox(node)
                .build();
        ObjsItem info = data.get("info");
        build.setProperty("weight",info.weight());
        build.setProperty("money",info.money());
        return build;
    }

    @Spawns("bigGlod")
    public Entity bigGlod(SpawnData data) {
        Texture node = new Texture(FXGL.image("glod/glod.png"));
        node.setFitWidth(node.getWidth() / 4);
        node.setFitHeight(node.getHeight() / 4);
        Entity build = FXGL.entityBuilder(data).zIndex(10)
                .at((Point2D) data.get("pos"))
                .type(TypeEnum.STONE).collidable()
                .viewWithBBox(node)
                .build();
        ObjsItem info = data.get("info");
        build.setProperty("weight",info.weight());
        build.setProperty("money",info.money());
        return build;
    }

    @Spawns("midGlod")
    public Entity midGold(SpawnData data) {
        Texture node = new Texture(FXGL.image("glod/mid_glod.png"));
        node.setFitWidth(node.getWidth() / 4);
        node.setFitHeight(node.getHeight() / 4);
        Entity build = FXGL.entityBuilder(data).zIndex(10)
                .at((Point2D) data.get("pos"))
                .type(TypeEnum.STONE).collidable()
                .viewWithBBox(node)
                .build();
        ObjsItem info = data.get("info");
        build.setProperty("weight",info.weight());
        build.setProperty("money",info.money());
        return build;
    }

    @Spawns("smallGlod")
    public Entity smallGlod(SpawnData data) {
        Texture node = new Texture(FXGL.image("glod/small_glod.png"));
        node.setFitWidth(node.getWidth() / 4);
        node.setFitHeight(node.getHeight() / 4);
        Entity build = FXGL.entityBuilder(data).zIndex(10)
                .at((Point2D) data.get("pos"))
                .type(TypeEnum.STONE).collidable()
                .viewWithBBox(node)
                .build();
        ObjsItem info = data.get("info");
        build.setProperty("weight",info.weight());
        build.setProperty("money",info.money());
        return build;
    }

    @Spawns("bag")
    public Entity bag(SpawnData data) {
        Texture node = new Texture(FXGL.image("other/bag.png"));
        node.setFitWidth(node.getWidth() / 4);
        node.setFitHeight(node.getHeight() / 4);
        Entity build = FXGL.entityBuilder(data).zIndex(10)
                .at((Point2D) data.get("pos"))
                .type(TypeEnum.STONE).collidable()
                .viewWithBBox(node)
                .build();
        ObjsItem info = data.get("info");
        build.setProperty("weight",info.weight());
        build.setProperty("money",info.money());
        return build;
    }

    @Spawns("diamond")
    public Entity diamond(SpawnData data) {
        Texture node = new Texture(FXGL.image("other/diamond.png"));
        node.setFitWidth(node.getWidth() / 4);
        node.setFitHeight(node.getHeight() / 4);
        Entity build = FXGL.entityBuilder(data).zIndex(10)
                .at((Point2D) data.get("pos"))
                .type(TypeEnum.STONE).collidable()
                .viewWithBBox(node)
                .build();
        ObjsItem info = data.get("info");
        build.setProperty("weight",info.weight());
        build.setProperty("money",info.money());
        return build;
    }

    @Spawns("head")
    public Entity head(SpawnData data) {
        Texture node = new Texture(FXGL.image("other/head.png"));
        node.setFitWidth(node.getWidth() / 4);
        node.setFitHeight(node.getHeight() / 4);
        Entity build = FXGL.entityBuilder(data).zIndex(10)
                .at((Point2D) data.get("pos"))
                .type(TypeEnum.STONE).collidable()
                .viewWithBBox(node)
                .build();
        ObjsItem info = data.get("info");
        build.setProperty("weight",info.weight());
        build.setProperty("money",info.money());
        return build;
    }



}
